
;; This transforms a color into a list of integer values using the
;; scaling used by the Gimp 'Color Selection' dialog, which is used to
;; verify correctness.  Notably the hue value is in (0,360) and
;; saturation and value are in (0,100).

(define (as-gimp c)
  (let ((f (lambda (a b) (floorE (* a b)))))
    (cond ((rgb? c) 
	   (map f (rgb->list c) '(255 255 255)))
	  ((hsv? c)
	   (map f (hsv->list c) '(360 100 100)))
	  ((rgb? c)
	   (rgb->list c)))))

(let* ((color (make-rgb 1/3 1/4 1/5))
       (out (rgb->hsv color))
       (back (hsv->rgb out)))
  (list (as-gimp color)
	(as-gimp out)
	(as-gimp back)))                  

;; => ((85 63 51) (22 40 33) (85 63 51))

(map as-gimp
     (map greyscale->rgb (iota 4 0 1/3)))

;; => ((255 255 255) (170 170 170) (85 85 85) (0 0 0))

(rgb->list 
 (rgb-average (make-rgb 1/3 1/4 1/5)
	      (make-rgb 1   0   1/2))) 

;; => (2/3 1/8 7/20)

(as-gimp 
 (gradient->hsv
  (make-hsv 0.1 0.1 0.1) (make-hsv 0.9 0.9 0.9) 0.5))	

;; => (180 50 50)

(bgra->list (bgra-interpolate 0.5 red green))

;; => (0 0.5 0.5 1.0)
